<?php

use yii\db\Migration;

class m000000_000019_create_article_tag_map extends Migration
{
    public function up()
    {
        $this->createTable('{{%article_tag_map}}', [
            'id'=>$this->primaryKey(), // PK
            'tid'=>$this->integer(), // 标签编号
            'aid'=>$this->integer(), // 资讯编号
        ]);
        $this->createIndex('fk_article_tag_map_article_tag1_idx', '{{%article_tag_map}}', ['tid']);
        try {
            $this->addForeignKey('fk_article_tag_map_article_tag1', '{{%article_tag_map}}', ['tid'], '{{%article_tag}}', ['id']);
        } catch (Exception $e) {
        }
        $this->createIndex('fk_article_tag_map_article1_idx', '{{%article_tag_map}}', ['aid']);
        try {
            $this->addForeignKey('fk_article_tag_map_article1', '{{%article_tag_map}}', ['aid'], '{{%article}}', ['id']);
        } catch (Exception $e) {
        }
    }

    public function down()
    {
        $this->dropTable('{{%article_tag_map}}');
    }
}
